<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head id="MyHead">
    <script src="../resources/Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="../resources/Scripts/jquery.easyui.min-1.3.5.js" type="text/javascript"></script>
    <script src="../resources/Scripts/jquery.datagrid.js" type="text/javascript"></script>
    <script src="../resources/Scripts/JScriptIndex.js" type="text/javascript"></script>
	<link href="../resources/Content/Default.css" rel="stylesheet" type="text/css" />
    <link href="../resources/Content/IndexStyle.css" rel="stylesheet" type="text/css" />
    <link href="../resources/css/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../resources/Script/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <link href="../resources/css/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <title>学员</title>
     <script type="text/javascript" language="javascript">
         $(function () {
             $.extend($.fn.datagrid.methods, {
                 addToolbarItem: function (jq, items) {
                     return jq.each(function () {
                         var dpanel = $(this).datagrid('getPanel');
                         var toolbar = dpanel.children("div.datagrid-toolbar");
                         if (!toolbar.length) {
                             toolbar = $("<div class=\"datagrid-toolbar\"><table cellspacing=\"0\" cellpadding=\"0\"><tr></tr></table></div>").prependTo(dpanel);
                             $(this).datagrid('resize');
                         }
                         var tr = toolbar.find("tr");
                         for (var i = 0; i < items.length; i++) {
                             var btn = items[i];
                             if (btn == "-") {
                                 $("<td><div class=\"datagrid-btn-separator\"></div></td>").appendTo(tr);
                             } else {
                                 var td = $("<td></td>").appendTo(tr);
                                 var b = $("<a href=\"javascript:void(0)\"></a>").appendTo(td);
                                 b[0].onclick = eval(btn.handler || function () { });
                                 b.linkbutton($.extend({}, btn, {
                                     plain: true
                                 }));
                             }
                         }
                     });
                 },
                 removeToolbarItem: function (jq, param) {
                     return jq.each(function () {
                         var dpanel = $(this).datagrid('getPanel');
                         var toolbar = dpanel.children("div.datagrid-toolbar");
                         var cbtn = null;
                         if (typeof param == "number") {
                             cbtn = toolbar.find("td").eq(param).find('span.l-btn-text');
                         } else if (typeof param == "string") {
                             cbtn = toolbar.find("span.l-btn-text:contains('" + param + "')");
                         }
                         if (cbtn && cbtn.length > 0) {
                             cbtn.closest('td').remove();
                             cbtn = null;
                         }
                     });
                 }
             });
         });
    </script>
    
    
    <script type="text/javascript" language="javascript">
        $(function () {

            $('#flexigridData').datagrid({
                title: '学员毕业列表', //列表的标题
                iconCls: 'icon-site',
                width: 'auto',
                height: 'auto',
                nowrap: true,
                striped: true,
                singleSelect: true,
                collapsible: true,
                url: '/show',//获取数据的url
                queryParams: {stuName: 'success'},
                sortName: 'stuId',
                sortOrder: 'desc',
                idField: 'stuId',

                toolbar: "#toolbar1",
                columns: [[


                    { field: 'stuId', title: '<label for="stuId">学员编号</label>', width: 80 }
                    , { field: 'stuName', title: '<label for="stuName">姓名</label>', width: 80 }
                    , { field: 'stuSex', title: '<label for="stuSex">性别</label>', width: 40 }
                    , { field: 'stuPhoto', title: '<label for="S_photos">照片</label>', width: 80
/*                     ,
                        formatter: function (value, rec) {
                            return photos(value);
                        } */
                    }
                    , { field: 'graTime', title: '<label for="graTime">毕业时间</label>', width: 80 
                  /*   , formatter: function (value, rec) {
                        if (value) {
                            return dateConvert(value);
                        }
                    } */
                    }
                    , { field: 'graStatus', title: '<label for="graStatus">发证状态</label>', width: 80 }
                    , { field: 'graPecipientsName', title: '<label for="graPecipientsName">发证领取人</label>', width: 80 } 
                    , { field: 'graPecipientsCardId', title: '<label for="graPecipientsCardId">领取人身份证</label>', width: 140 }
                    , { field: 'graPecipientsPhone', title: '<label for="graPecipientsPhone">领取人电话</label>', width: 100 }
                    , { field: 'graReceiveTime', title: '<label for="graReceiveTime">领证时间</label>', width: 80,
                    
                    }
                     , { field: 'graLicenseId', title: '<label for="graLicenseId">驾照证码</label>', width: 140 }


                    , { field: 'stuAddress', title: '<label for="S_tel">家庭住址</label>', width: 80 }
                    , { field: 'stuPhone', title: '<label for="S_mob">手机</label>', width: 80 }
                    , { field: 'stuClassType', title: '<label for="FK_CaridOld">班别</label>', width: 80 }
                    , { field: 'stuAssignsSchool', title: '<label for="FK_DIC_from">报名分校</label>', width: 80 }
                    , { field: 'graValadityBegintime', title: '有效期<label for="S_Perdate">开始日期</label>', width: 100
/*                     , formatter: function (value, rec) {
                        if (value) {
                            return dateConvert(value);
                        }
                    } */
                                        }
                    , { field: 'stuApplyDate', title: '<label for="stuApplyDate">报名日期</label>', width: 80 }
/*                     , formatter: function (value, rec) {
                        if (value) {
                            return dateConvert(value);
                        }
                    } */
                    
/*                     , formatter: function (value, rec) {
                        if (value) {
                            return dateConvert(value);
                        }
                    } */

                ]],
                pagination: true,
                rownumbers: true

            });
            $("#fendianID").combobox({ panelHeight: 'auto', editable: false });
            $("#8").combobox({
                editable: false,
                onSelect: function (record) {

                    $.ajax({
                        type: "POST",
                        url: '../../SysPerson/getSelData/?table=StudentSource&colum=models&pid=' + record.value,
                        dataType: 'json',
                        success: function (jsonstr) {
                            // 修改ajax返回的值
                            jsonstr.push({
                                'id': '',
                                'text': '全部',
                                "selected": true
                            });
                            $("#fendianID").combobox({ data: jsonstr, panelHeight: 'auto', editable: true, valueField: 'id', textField: 'text' });
                        }
                    });
                }
            });
        });

        ////////////////管理员回访
        var search1 = ''; //FK_DIC_Start&noway^
        //“导出EXCEL”按钮     在6.0版本中修改
        
        function flexiExport() {
            $.messager.confirm('操作提示', "确认要导出EXCEL！", function (r) {
                if (r) {
                    window.location.href = '/exportBiYeXueYuan';
                }
            });
        }
        
        function progress() {
            var win = $.messager.progress({
                title: '请等待',
                text: '数据正在处理中'
            });
        }

        //查询
        function FindData() {

            //var search = 'S_IsBiYeStart_Int&1^S_IsBiYeEnd_Int&1^S_IsGuiDangStart_Int&2^S_IsGuiDangEnd_Int&2^FK_DIC_Start&201211301122097187500e7a08003fe^';

            var stuId = document.getElementById("stuId").value; 
            var stuName = document.getElementById("stuName").value;
            var graTime = document.getElementById("graTime").value;
            /* var graStatus = $("#graStatus").combobox("getValue"); */
            var graStatus = document.getElementById("graStatus1").value;
            /* var options = document.getElementByTagName("option"); */
            console.log(graStatus);

         /*    search1 += search;
            //$('#flexigridData').datagrid('reload', { search: search }); */
            $('#flexigridData').datagrid('reload', {stuId:stuId,stuName:stuName,graTime:graTime,graStatus:graStatus});
        }

        function guidangOpert(obj, action) {
            var rows = $('#' + obj).datagrid('getSelections');
            if (rows.length == 0) {
                $.messager.alert('操作提示', '请选择数据!', 'warning');
                return false;
            }
            var arr = [];
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].graStatus.replace(/<[^>]+>/g, "") == "已发证") {
                    alert("学员："+rows[i].stuName.replace(/<[^>]+>/g, "") + "   已经发证不能取消归档");
                    arr = "";
                    return;
                    break;
                }
                arr.push(rows[i].stuId);
            }
            $.messager.defaults = { ok: "确认", cancel: "取消" };
            $.messager.confirm('操作提示', "确认操作这 " + arr.length + " 项吗？", function (r) {
                if (r) {
                    $.post("../../S_student/guidangOpert", { pkids: arr.join(","), action: action }, function (res) {

                        if (res == "OK") {
                            //移除删除的数据
                            $.messager.alert('操作提示', '修改成功!', 'warning');

                            $("#" + obj).datagrid("reload");
                            $("#" + obj).datagrid("clearSelections");

                        }
                        else {
                            $.messager.alert('操作提示', res, 'warning');
                        }
                    });
                }
            });
        }
        function fazheng(obj, action) {
            
            var rows = $('#' + obj).datagrid('getSelections');
            if (rows.length == 0) {
                $.messager.alert('操作提示', '请选择数据!', 'warning');
                return false;
            }
            if (rows.length >1) {
                $.messager.alert('操作提示', '只能选择1条数据!', 'warning');
                return false;
            }

            var arr = [];
            for (var i = 0; i < rows.length; i++) {
                arr.push(rows[i].stuId);
            }
            
            var stuName= document.getElementById("graPecipientsName").value;
            var stuCardId = document.getElementById("stuCardId").value;
            var graPecipientsPhone = document.getElementById("graPecipientsPhone").value;
            var graReceiveTime = document.getElementById("graReceiveTime").value;
            var graLicenseId = document.getElementById("graLicenseId").value;
           
                    $.post("/issuance", {stuId:rows[0].stuId,stuName:stuName,stuCardId:stuCardId,graPecipientsPhone:graPecipientsPhone,graReceiveTime:graReceiveTime,graLicenseId:graLicenseId}, function (res) {

                        if (res == "OK") {
                            $('#divFaZheng').dialog("close");
                            alert("发证完成!!!!");
                            
                            $("#" + obj).datagrid("reload");
                            $("#" + obj).datagrid("clearSelections");

                        }
                        else {
                            $.messager.alert('操作提示', "错误", 'warning');
                        }
                    });
              
            
        }
        function showFaZheng() {

            var rows = $('#flexigridData').datagrid('getSelections');
            if (rows.length == 0) {
                $.messager.alert('操作提示', '请选择数据!', 'warning');
                return false;
            }
            if (rows.length > 1) {
                $.messager.alert('操作提示', '只能选择1条数据!', 'warning');
                return false;
            }
            var arr = [];
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].graStatus.replace(/<[^>]+>/g, "") == "已发证") {
                    alert("学员："+rows[i].stuName.replace(/<[^>]+>/g, "") + "   已经发证不能再次发放证件");
                    arr = "";
                    return;
                    break;
                }
                arr.push(rows[i].stuId);
            }
            $.messager.defaults = { ok: "本人领取", cancel: "他人代领" };
            $.messager.confirm("操作提示", "是学员本人来领取的吗？", function (data) {
            	console.log(rows[0]);
                if (data) {
 /*                    document.getElementById("stuName").value = (rows[0].stuName.replace(/<[^>]+>/g,"") ); 
 					$("#stuName").val(rows[0].stuName.replace(/<[^>]+>/g,""));*/
 					document.getElementById("graPecipientsName").value = rows[0].stuName;
                    document.getElementById("stuCardId").value =("");
                    document.getElementById("graPecipientsPhone").value = (rows[0].stuPhone);
                    
                    document.getElementById("graReceiveTime").value = ("");
                    document.getElementById("graLicenseId").value = ("");
                }
                else {
                    document.getElementById("graPecipientsName").value = ("");
                    document.getElementById("stuCardId").value = ("");
                    document.getElementById("graPecipientsPhone").value = ("");
                    document.getElementById("graReceiveTime").value = ('');
                    document.getElementById("graLicenseId").value = ("");
                }
                $('#divFaZheng').dialog("open");
            });
           
        }
    </script>
    <script src="../resources/Res/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

      <base target = "_self">
</head>
<body class="easyui-layout" style="padding:3px;">
    <table id="flexigridData" fit="true">
    </table>
    <div id="divFaZheng" class="easyui-dialog" title="发证信息" data-options="modal:true,closed:true,minimizable:false,collapsible:false,maximizable:false,iconCls:'icon-ok'" style="width:380px;height:300px;padding:10px;">
        <style type="text/css">
             .txrow{ width:340px; margin:0 auto; height:36px; overflow:hidden;zoom:1;}
             .txrow .left{ width:80px; text-align:left; display:block; float:left;}
             .txrow .right{ width:230px; text-align:left; display:block; float:left;}
        </style>
        <br />
        <div class="txrow"><span class="left">领取人姓名：</span><span class="right"><input type="text" class="input-textbox" style="width:196px;" id="graPecipientsName" name="stuName"  /></span></div>
        <div class="txrow"><span class="left">领取人电话：</span><span class="right"><input type="text" class="input-textbox" style="width:196px;" id="graPecipientsPhone" name="graPecipientsPhone"  /></span></div>
        <div class="txrow"><span class="left">领取人身份证：</span><span class="right"><input type="text" class="input-textbox" style="width:196px;" id="stuCardId"  name="stuCardId" /></span></div>
        <div class="txrow"><span class="left">领证时间：</span><span class="right"><input type="text" class="input-textbox" style="width:196px;"  id="graReceiveTime" name="graReceiveTime" value='2018-01-17' onclick="WdatePicker({maxDate:'#F{$dp.$D(\'graReceiveTime\');}'})"  /></span></div>
        <div class="txrow"><span class="left">领证证号：</span><span class="right"><input type="text" class="input-textbox" style="width:196px;" id="graLicenseId" name="graLicenseId" /></span></div>
        <div class="txrow"><span class="left">&nbsp;</span><span class="right"><a href="javascript:void(0);" onclick="fazheng('flexigridData','fazheng');" id="printbutton" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">确认提交</a> </span></div>
    </div>

    <div id="toolbar1" style="padding:5px;height:auto">
        <div style="margin-bottom:5px">
			<!--             <a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick='guidangOpert("flexigridData","noguidang");' plain="true">取消已归档</a> -->
			&nbsp;&nbsp;<a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick='showFaZheng();' plain="true">发放驾照</a>
            &nbsp;&nbsp;<a href="#" class="easyui-linkbutton" iconCls="icon-excel" onclick='flexiExport();' plain="true">导出EXCEL</a>
         
        </div>
        <div>
            学员编号: <input class="input-textbox" type='text' id="stuId">&nbsp;&nbsp;
            学员姓名: <input class="input-textbox" type='text' id='stuName' />&nbsp;&nbsp;        
            毕业日期: <input class="input-textbox" id="graTime" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'graTime\');}'})">
            &nbsp;
           &nbsp;
            发证状态： 
            <select  id="graStatus1" name="graStatus1" panelHeight="auto" style="width:100px;">
                <option value="">请选择</option>
                <option value="已发证">已发证</option>
                <option value="未发证">未发证</option>
            </select>
           <a href="javascript:void(0);" onclick="FindData();" class="easyui-linkbutton" iconCls="icon-search">查询</a>
        </div>
</div>
</body>
</html>



